//
//  SEInspListResultVC.swift
//  SBSafetyApp
//
//  Created by Lina on 2022/12/11.
//
// 【首页-维保服务】维修工程师-巡检结果

import Foundation
import UIKit

class SEInspListResultVC: SubLevelViewController {
    let detailV = SEInspListResultView()
    
    var modal: InspResultParam?
    
    open var didSelectItemWith:((_ item: InspResultParam) -> ())?
    
    init(withModal _modal: InspResultParam) {
        super.init(nibName: nil, bundle: nil)
        self.modal = _modal
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        title = "巡检结果"
        view.backgroundColor = .bg
        setupUI()
        reloadData()
    }
    
    func reloadData() {
        detailV.updateUI(withModal: modal)
    }    
    
    @objc func submitTapped() {
        detailV.recordParam.summary = detailV.ycqksmItem.value
        detailV.recordParam.images = detailV.imgPickerView.images
        didSelectItemWith?(detailV.recordParam)
        self.navigationController?.popViewController(animated: true)
    }
    
    func setupUI() {
        detailV.submitBtn.addTarget(self, action: #selector(submitTapped), for: .touchUpInside)
        view.addSubview(detailV)
        detailV.snp.makeConstraints { (make) in
            make.left.right.equalToSuperview()
            make.top.equalTo(view.safeAreaLayoutGuide.snp.top)
            make.bottom.equalTo(view.safeAreaLayoutGuide.snp.bottom)
        }
    }
}
